package com.xpxrule.controller.match;

import com.xpxrule.dataobject.biz.model.ReturnResponse;
import com.xpxrule.dataobject.req.RuleMatchReq;
import com.xpxrule.dataobject.vo.RuleVo;
import com.xpxrule.service.RuleMatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @version 1.0
 * @Author xiangpengxiang
 * @Date 2024/11/18 19:42
 * @注释
 */
@RestController
@RequestMapping("/ruleMatch")
public class MatchController {
    @Autowired
    private RuleMatchService ruleMatchService;

    /**
     * 规则匹配
     * @param request
     * @return
     */
    @PostMapping("/match")
    public ReturnResponse<List<RuleVo>> match(@RequestBody RuleMatchReq request) {
        // 参数校验
        List<RuleVo> ruleVoList = ruleMatchService.matchRule(request);
        return new ReturnResponse<List<RuleVo>>().success(ruleVoList);
    }
}
